package ModelLayer;
import java.util.ArrayList;


public class Discounts
{
    //instance variables
    private static Discounts instance = null;
    private static ArrayList<Discount> discounts;
   
    /**
     * Empty constructor for testing purposes
     */
    
    private Discounts()
    {
       discounts = new ArrayList<Discount>();
    }
    
    /**
     * Singleton static inplementation
     */
    
    public static Discounts getInstance()
    {
      if(instance == null)
      {
        instance = new Discounts();
      }
      return instance;
    }
   
     /**
     * Accessor and Mutator methods
     */
    
    public static void addDiscount(Discount _discount)
    {
        discounts.add(_discount);
    }
    
    public static Discount getDiscount(String _id)
    {
        Discount d = new Discount();
        for(int i = 0; i<discounts.size(); i++)  
        {
            if (discounts.get(i).getId().equals(_id))
                d = discounts.get(i);
        }
        return d;
    }
        
    public static int getSize()
    {
        return discounts.size();
    }
}
